
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 06/18/2013 11:53:22
-- Generated from EDMX file: C:\Users\Tito\Documents\Visual Studio 2012\Projects\Fiscalizacion\Fiscalizacion\AccesoDatos\ModeloEntiadades.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [Colegio-de-medicos-prototipo];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_Consultorio_alta_consultorio]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consultorio_alta] DROP CONSTRAINT [FK_Consultorio_alta_consultorio];
GO
IF OBJECT_ID(N'[dbo].[FK_Consultorio_alta_titular]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consultorio_alta] DROP CONSTRAINT [FK_Consultorio_alta_titular];
GO
IF OBJECT_ID(N'[dbo].[FK_Consultorio_profesionales_alta]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consultorio_profesionales] DROP CONSTRAINT [FK_Consultorio_profesionales_alta];
GO
IF OBJECT_ID(N'[dbo].[FK_Consultorio_rematriculaciones]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Consultorio_rematriculaciones] DROP CONSTRAINT [FK_Consultorio_rematriculaciones];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Consultorio_alta]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consultorio_alta];
GO
IF OBJECT_ID(N'[dbo].[Consultorio_consultorio]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consultorio_consultorio];
GO
IF OBJECT_ID(N'[dbo].[Consultorio_profesionales]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consultorio_profesionales];
GO
IF OBJECT_ID(N'[dbo].[Consultorio_rematriculaciones]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consultorio_rematriculaciones];
GO
IF OBJECT_ID(N'[dbo].[Consultorio_titular]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Consultorio_titular];
GO
IF OBJECT_ID(N'[ModeloEntidadesStoreContainer].[tramitesEnCurso]', 'U') IS NOT NULL
    DROP TABLE [ModeloEntidadesStoreContainer].[tramitesEnCurso];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Consultorio_alta'
CREATE TABLE [dbo].[Consultorio_alta] (
    [id] int IDENTITY(1,1) NOT NULL,
    [numero_tramite] nchar(9)  NULL,
    [fecha_inicio_tramite] datetime  NULL,
    [numero_acta] nchar(10)  NULL,
    [fecha_habilitacion] datetime  NULL,
    [fecha_vencimiento] datetime  NULL,
    [numero_matriculacion_ministerio] nchar(10)  NULL,
    [titular_id] int  NULL,
    [consultorio_id] int  NULL
);
GO

-- Creating table 'Consultorio_consultorio'
CREATE TABLE [dbo].[Consultorio_consultorio] (
    [id] int IDENTITY(1,1) NOT NULL,
    [nombre_razon_social] nchar(70)  NULL,
    [tipo] bit  NULL,
    [localidad] nchar(50)  NULL,
    [departamento] nchar(50)  NULL,
    [cp] nchar(30)  NULL,
    [domicilio] nchar(50)  NULL,
    [telefono] nchar(12)  NULL,
    [email] nchar(255)  NULL,
    [propietario] bit  NULL,
    [titular_propiedad] nchar(70)  NULL,
    [plano_municipal] bit  NULL,
    [plano_contingencia] bit  NULL
);
GO

-- Creating table 'Consultorio_profesionales'
CREATE TABLE [dbo].[Consultorio_profesionales] (
    [id] int IDENTITY(1,1) NOT NULL,
    [numero_colegio] nchar(10)  NULL,
    [plantel_profesional] nchar(70)  NULL,
    [dedicacion_especialidad] nchar(60)  NULL,
    [matricula] nchar(10)  NULL,
    [fecha_incorporacion] datetime  NULL,
    [alta_id] int  NULL,
    [cuota_colegiacion] bit  NULL,
    [certificado] bit  NULL,
    [del_colegio] bit  NULL
);
GO

-- Creating table 'Consultorio_rematriculaciones'
CREATE TABLE [dbo].[Consultorio_rematriculaciones] (
    [id] int IDENTITY(1,1) NOT NULL,
    [numero_acta] nchar(10)  NULL,
    [fecha] datetime  NULL,
    [alta_id] int  NOT NULL
);
GO

-- Creating table 'Consultorio_titular'
CREATE TABLE [dbo].[Consultorio_titular] (
    [id] int IDENTITY(1,1) NOT NULL,
    [nombre] nchar(70)  NULL,
    [apellido] nchar(70)  NULL,
    [dni] nchar(8)  NULL,
    [domicilio] nchar(60)  NULL,
    [telefono] nchar(12)  NULL,
    [celular] nchar(13)  NULL,
    [email] nchar(255)  NULL,
    [email_auxiliar] nchar(255)  NULL,
    [numero_matricula] nchar(10)  NULL,
    [del_colegio] bit  NULL
);
GO

-- Creating table 'tramitesEnCursoes'
CREATE TABLE [dbo].[tramitesEnCursoes] (
    [id] int  NOT NULL,
    [numero_tramite] nchar(9)  NULL,
    [fecha_inicio_tramite] datetime  NULL,
    [numero_acta] nchar(10)  NULL,
    [nombre_razon_social] nchar(70)  NULL,
    [nombre] nchar(70)  NULL,
    [apellido] nchar(70)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [id] in table 'Consultorio_alta'
ALTER TABLE [dbo].[Consultorio_alta]
ADD CONSTRAINT [PK_Consultorio_alta]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Consultorio_consultorio'
ALTER TABLE [dbo].[Consultorio_consultorio]
ADD CONSTRAINT [PK_Consultorio_consultorio]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Consultorio_profesionales'
ALTER TABLE [dbo].[Consultorio_profesionales]
ADD CONSTRAINT [PK_Consultorio_profesionales]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Consultorio_rematriculaciones'
ALTER TABLE [dbo].[Consultorio_rematriculaciones]
ADD CONSTRAINT [PK_Consultorio_rematriculaciones]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'Consultorio_titular'
ALTER TABLE [dbo].[Consultorio_titular]
ADD CONSTRAINT [PK_Consultorio_titular]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [id] in table 'tramitesEnCursoes'
ALTER TABLE [dbo].[tramitesEnCursoes]
ADD CONSTRAINT [PK_tramitesEnCursoes]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [consultorio_id] in table 'Consultorio_alta'
ALTER TABLE [dbo].[Consultorio_alta]
ADD CONSTRAINT [FK_Consultorio_alta_consultorio]
    FOREIGN KEY ([consultorio_id])
    REFERENCES [dbo].[Consultorio_consultorio]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Consultorio_alta_consultorio'
CREATE INDEX [IX_FK_Consultorio_alta_consultorio]
ON [dbo].[Consultorio_alta]
    ([consultorio_id]);
GO

-- Creating foreign key on [titular_id] in table 'Consultorio_alta'
ALTER TABLE [dbo].[Consultorio_alta]
ADD CONSTRAINT [FK_Consultorio_alta_titular]
    FOREIGN KEY ([titular_id])
    REFERENCES [dbo].[Consultorio_titular]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Consultorio_alta_titular'
CREATE INDEX [IX_FK_Consultorio_alta_titular]
ON [dbo].[Consultorio_alta]
    ([titular_id]);
GO

-- Creating foreign key on [alta_id] in table 'Consultorio_profesionales'
ALTER TABLE [dbo].[Consultorio_profesionales]
ADD CONSTRAINT [FK_Consultorio_profesionales_alta]
    FOREIGN KEY ([alta_id])
    REFERENCES [dbo].[Consultorio_alta]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Consultorio_profesionales_alta'
CREATE INDEX [IX_FK_Consultorio_profesionales_alta]
ON [dbo].[Consultorio_profesionales]
    ([alta_id]);
GO

-- Creating foreign key on [alta_id] in table 'Consultorio_rematriculaciones'
ALTER TABLE [dbo].[Consultorio_rematriculaciones]
ADD CONSTRAINT [FK_Consultorio_rematriculaciones]
    FOREIGN KEY ([alta_id])
    REFERENCES [dbo].[Consultorio_alta]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_Consultorio_rematriculaciones'
CREATE INDEX [IX_FK_Consultorio_rematriculaciones]
ON [dbo].[Consultorio_rematriculaciones]
    ([alta_id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------